package com.win.controller;

import com.win.pojo.Person;
import com.win.service.Persons;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    // 如果person.name为null 则为李四
    @Value("${person.name:李四}")
    private String name;

    @RequestMapping("/hello1")
    public String hello1() {
        return name;
    }

    @Autowired
    private Person person;
    @Autowired
    private Persons persons;

    @GetMapping("/")
    public Person hello() {
        // 激活了 prod，则返回 Boss；激活了 test，则返回 Worker
//        Person person = new Person();
//        person.setName("张三");
//        person.setAge(18);
        return person;
    }
    @GetMapping("/persons")
    public String persons() {
        // 激活了 prod，则返回 Boss；激活了 test，则返回 Worker
//        Person person = new Person();
//        person.setName("张三");
//        person.setAge(18);
        return persons.getClass().toString();
    }



}
